define(['app'],function(app) {
	return {module: function($scope, $http, eventBusService, httpService, params, configService) {
		$scope.form = {};

		httpService.post(app.urls.rule_selectIcon,{},function(data){
			if("0000" === data.code){
				$scope.icons = data.data;
			}else{
				alert(data.msg);
			}
		});		
        httpService.post(app.urls.menu_selectById, {"id" : params.id}, function(data) {
            if(data.code == "0000") {
                $scope.form = data.data;
            }else{
                eventBusService.publish("modal.alert", {"content":data.msg});
            }
        });

    	//保存
    	$scope.save = function() {
    		if(!$scope.formCheck()) {
                return;
            }

			httpService.post(app.urls.menu_update, $scope.form, function(data) {
    			if(data.code == "0000") {
    			     eventBusService.publish("modal.page.close",{});
                     eventBusService.publish("content.page.reload", data.data);
    			}else{
    				eventBusService.publish("modal.alert", {"content":data.msg});
    			}
            });
        };
	}
}});
